package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.Keshi2;
import com.ruoyi.service.IKeshi2Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 科室2Controller
 * 
 * @author ya
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/keshi2/keshi2")
public class Keshi2Controller extends BaseController
{
    @Autowired
    private IKeshi2Service keshi2Service;

    /**
     * 查询科室2列表 全部
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(Keshi2 keshi2)
    {
        //startPage();
        List<Keshi2> list = keshi2Service.selectKeshi2List(keshi2);
        return getDataTable(list);
    }

    /**
     * 查询科室2列表
     */
    @Anonymous
    @GetMapping("/list/ruoyi")
    public TableDataInfo list1(Keshi2 keshi2)
    {
        startPage();
        List<Keshi2> list = keshi2Service.selectKeshi2List(keshi2);
        return getDataTable(list);
    }

    /**
     * 导出科室2列表
     */
    @Anonymous
    @Log(title = "科室2", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Keshi2 keshi2)
    {
        List<Keshi2> list = keshi2Service.selectKeshi2List(keshi2);
        ExcelUtil<Keshi2> util = new ExcelUtil<Keshi2>(Keshi2.class);
        util.exportExcel(response, list, "科室2数据");
    }

    /**
     * 获取科室2详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(keshi2Service.selectKeshi2ById(id));
    }

    /**
     * 新增科室2
     */
    @Anonymous
    @Log(title = "科室2", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Keshi2 keshi2)
    {
        return toAjax(keshi2Service.insertKeshi2(keshi2));
    }

    /**
     * 修改科室2
     */
    @Anonymous
    @Log(title = "科室2", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Keshi2 keshi2)
    {
        return toAjax(keshi2Service.updateKeshi2(keshi2));
    }

    /**
     * 删除科室2
     */
    @Anonymous
    @Log(title = "科室2", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(keshi2Service.deleteKeshi2ByIds(ids));
    }
}
